package com.zlf.sb.demo.ms;

import java.util.concurrent.CountDownLatch;

/***
 *@title ThreadTest
 *@description <TODO description class purpose>
 *@author wgc_j
 *@version 1.0.0
 *@create 2025-02-24 13:19
 **/
public class ThreadTest {
    public static void main(String[] args) {
        CountDownLatch countDownLatch1 = new CountDownLatch(1);
        CountDownLatch countDownLatch2 = new CountDownLatch(1);
        CountDownLatch countDownLatch3 = new CountDownLatch(1);
        Thread thread1 = new Thread(() -> {
            System.out.println("线程1开始执行");
            countDownLatch1.countDown();
        });
        Thread thread2 = new Thread(() -> {
             try {
                 countDownLatch1.await();
                  System.out.println("线程2开始执行");
                  countDownLatch2.countDown();
             }catch (InterruptedException e){
                e.printStackTrace();
             }
        });


        Thread thread3 = new Thread(() -> {
            try {
                countDownLatch2.await();
                System.out.println("线程3开始执行");
                countDownLatch3.countDown();
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        });
        Thread thread4 = new Thread(() -> {
            try {
                countDownLatch3.await();
                System.out.println("线程4开始执行");

            }catch (InterruptedException e){
                e.printStackTrace();
            }
        });
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
    }


}
